<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
	<title>Index stats API | ElasticSearch 7.7 权威指南中文版</title>
	<meta name="keywords" content="ElasticSearch 权威指南中文版, elasticsearch 7, es7, 实时数据分析，实时数据检索" />
    <meta name="description" content="ElasticSearch 权威指南中文版, elasticsearch 7, es7, 实时数据分析，实时数据检索" />
    <!-- Give IE8 a fighting chance -->
    <!--[if lt IE 9]>
    <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
    <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->
	<link rel="stylesheet" type="text/css" href="../static/styles.css" />
	<script>
	var _link = 'indices-stats.html';
    </script>
</head>
<body>
<div class="main-container">
    <section id="content">
        <div class="content-wrapper">
            <section id="guide" lang="zh_cn">
                <div class="container">
                    <div class="row">
                        <div class="col-xs-12 col-sm-8 col-md-8 guide-section">
                            <div style="color:gray; word-break: break-all; font-size:12px;">原英文版地址: <a href="https://www.elastic.co/guide/en/elasticsearch/reference/7.7/indices-stats.html" rel="nofollow" target="_blank">https://www.elastic.co/guide/en/elasticsearch/reference/7.7/indices-stats.html</a>, 原文档版权归 www.elastic.co 所有<br/>本地英文版地址: <a href="../en/indices-stats.html" rel="nofollow" target="_blank">../en/indices-stats.html</a></div>
                        <!-- start body -->
                  <div class="page_header">
<strong>重要</strong>: 此版本不会发布额外的bug修复或文档更新。最新信息请参考 <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/index.html" rel="nofollow">当前版本文档</a>。
</div>
<div id="content">
<div class="breadcrumbs">
<span class="breadcrumb-link"><a href="index.html">Elasticsearch Guide [7.7]</a></span>
»
<span class="breadcrumb-link"><a href="rest-apis.html">REST APIs</a></span>
»
<span class="breadcrumb-link"><a href="indices.html">Index APIs</a></span>
»
<span class="breadcrumb-node">Index stats API</span>
</div>
<div class="navheader">
<span class="prev">
<a href="indices-shards-stores.html">« Index shard stores API</a>
</span>
<span class="next">
<a href="indices-template-exists.html">Index template exists API »</a>
</span>
</div>
<div class="section">
<div class="titlepage"><div><div>
<h2 class="title">
<a id="indices-stats"></a>Index stats API<a class="edit_me edit_me_private" rel="nofollow" title="Editing on GitHub is available to Elastic" href="https://github.com/elastic/elasticsearch/edit/7.7/docs/reference/indices/stats.asciidoc">edit</a>
</h2>
</div></div></div>

<p>Returns statistics for an index.</p>
<div class="pre_wrapper lang-console">
<pre class="programlisting prettyprint lang-console">GET /twitter/_stats</pre>
</div>
<div class="console_widget" data-snippet="snippets/1679.console"></div>
<div class="section">
<div class="titlepage"><div><div>
<h3 class="title">
<a id="index-stats-api-request"></a>Request<a class="edit_me edit_me_private" rel="nofollow" title="Editing on GitHub is available to Elastic" href="https://github.com/elastic/elasticsearch/edit/7.7/docs/reference/indices/stats.asciidoc">edit</a>
</h3>
</div></div></div>
<p><code class="literal">GET /&lt;index&gt;/_stats/&lt;index-metric&gt;</code></p>
<p><code class="literal">GET /&lt;index&gt;/_stats</code></p>
<p><code class="literal">GET /_stats</code></p>
</div>

<div class="section">
<div class="titlepage"><div><div>
<h3 class="title">
<a id="index-stats-api-desc"></a>Description<a class="edit_me edit_me_private" rel="nofollow" title="Editing on GitHub is available to Elastic" href="https://github.com/elastic/elasticsearch/edit/7.7/docs/reference/indices/stats.asciidoc">edit</a>
</h3>
</div></div></div>
<p>Use the index stats API to get high-level aggregation and statistics for an index.</p>
<p>By default,
the returned statistics are index-level
with <code class="literal">primaries</code> and <code class="literal">total</code> aggregations.
<code class="literal">primaries</code> are the values for only the primary shards.
<code class="literal">total</code> are the accumulated values for both primary and replica shards.</p>
<p>To get shard-level statistics,
set the <code class="literal">level</code> parameter to <code class="literal">shards</code>.</p>
<div class="note admon">
<div class="icon"></div>
<div class="admon_content">
<p>When moving to another node,
the shard-level statistics for a shard are cleared.
Although the shard
is no longer part of the node,
that node retains any node-level statistics
to which the shard contributed.</p>
</div>
</div>
</div>

<div class="section">
<div class="titlepage"><div><div>
<h3 class="title">
<a id="index-stats-api-path-params"></a>Path parameters<a class="edit_me edit_me_private" rel="nofollow" title="Editing on GitHub is available to Elastic" href="https://github.com/elastic/elasticsearch/edit/7.7/docs/reference/indices/stats.asciidoc">edit</a>
</h3>
</div></div></div>
<div class="variablelist">
<dl class="variablelist">
<dt>
<span class="term">
<code class="literal">&lt;index&gt;</code>
</span>
</dt>
<dd>
<p>
(Optional, string) Comma-separated list or wildcard expression of index names
used to limit the request.
</p>
<p>To retrieve statistics for all indices,
use a value of <code class="literal">_all</code> or <code class="literal">*</code> or omit this parameter.</p>
</dd>
<dt>
<span class="term">
<code class="literal">&lt;index-metric&gt;</code>
</span>
</dt>
<dd>
<p>(Optional, string)
Comma-separated list of metrics used to limit the request.
Supported metrics are:</p>
<div class="variablelist">
<dl class="variablelist">
<dt>
<span class="term">
<code class="literal">_all</code>
</span>
</dt>
<dd>
Return all statistics.
</dd>
<dt>
<span class="term">
<code class="literal">completion</code>
</span>
</dt>
<dd>
<a class="xref" href="search-suggesters.html#completion-suggester" title="Completion Suggester">Completion suggester</a> statistics.
</dd>
<dt>
<span class="term">
<code class="literal">docs</code>
</span>
</dt>
<dd>
Number of documents and deleted docs, which have not yet merged out.
<a class="xref" href="indices-refresh.html" title="Refresh API">Index refreshes</a> can affect this statistic.
</dd>
<dt>
<span class="term">
<code class="literal">fielddata</code>
</span>
</dt>
<dd>
<a class="xref" href="fielddata.html" title="fielddata">Fielddata</a> statistics.
</dd>
<dt>
<span class="term">
<code class="literal">flush</code>
</span>
</dt>
<dd>
<a class="xref" href="indices-flush.html" title="Flush API">Flush</a> statistics.
</dd>
<dt>
<span class="term">
<code class="literal">get</code>
</span>
</dt>
<dd>
Get statistics,
including missing stats.
</dd>
<dt>
<span class="term">
<code class="literal">indexing</code>
</span>
</dt>
<dd>
<a class="xref" href="docs-index_.html" title="Index API">Indexing</a> statistics.
</dd>
<dt>
<span class="term">
<code class="literal">merge</code>
</span>
</dt>
<dd>
<a class="xref" href="index-modules-merge.html" title="Merge">Merge</a> statistics.
</dd>
<dt>
<span class="term">
<code class="literal">query_cache</code>
</span>
</dt>
<dd>
<a class="xref" href="query-cache.html" title="Node query cache settings">Query cache</a> statistics.
</dd>
<dt>
<span class="term">
<code class="literal">refresh</code>
</span>
</dt>
<dd>
<a class="xref" href="indices-refresh.html" title="Refresh API">Refresh</a> statistics.
</dd>
<dt>
<span class="term">
<code class="literal">request_cache</code>
</span>
</dt>
<dd>
<a class="xref" href="shard-request-cache.html" title="Shard request cache settings">Shard request cache</a> statistics.
</dd>
<dt>
<span class="term">
<code class="literal">search</code>
</span>
</dt>
<dd>
Search statistics including suggest statistics.
You can include statistics for custom groups
by adding an extra <code class="literal">groups</code> parameter
(search operations can be associated with one or more groups).
The <code class="literal">groups</code> parameter accepts a comma separated list of group names.
Use <code class="literal">_all</code> to return statistics for all groups.
</dd>
<dt>
<span class="term">
<code class="literal">segments</code>
</span>
</dt>
<dd>
<p>
Memory use of all open segments.
</p>
<p>If the <code class="literal">include_segment_file_sizes</code> parameter is <code class="literal">true</code>,
this metric includes the aggregated disk usage
of each Lucene index file.</p>
</dd>
<dt>
<span class="term">
<code class="literal">store</code>
</span>
</dt>
<dd>
Size of the index in <a class="xref" href="common-options.html#byte-units" title="Byte size units">byte units</a>.
</dd>
<dt>
<span class="term">
<code class="literal">suggest</code>
</span>
</dt>
<dd>
<a class="xref" href="search-suggesters.html" title="Suggesters">Suggester</a> statistics.
</dd>
<dt>
<span class="term">
<code class="literal">translog</code>
</span>
</dt>
<dd>
<a class="xref" href="index-modules-translog.html" title="Translog">Translog</a> statistics.
</dd>
<dt>
<span class="term">
<code class="literal">warmer</code>
</span>
</dt>
<dd>
<a class="xref" href="indices-warmers.html" title="Warmers">Warmer</a> statistics.
</dd>
</dl>
</div>
</dd>
</dl>
</div>
</div>

<div class="section">
<div class="titlepage"><div><div>
<h3 class="title">
<a id="index-stats-api-query-params"></a>Query parameters<a class="edit_me edit_me_private" rel="nofollow" title="Editing on GitHub is available to Elastic" href="https://github.com/elastic/elasticsearch/edit/7.7/docs/reference/indices/stats.asciidoc">edit</a>
</h3>
</div></div></div>
<div class="variablelist">
<dl class="variablelist">
<dt>
<span class="term">
<code class="literal">expand_wildcards</code>
</span>
</dt>
<dd>
<p>(Optional, string) Controls what kind of indices that wildcard expressions can
expand to. Multiple values are accepted when separated by a comma, as in
<code class="literal">open,hidden</code>. Valid values are:</p>
<div class="variablelist">
<dl class="variablelist">
<dt>
<span class="term">
<code class="literal">all</code>
</span>
</dt>
<dd>
Expand to open and closed indices, including <a class="xref" href="index-modules.html#index-hidden">hidden indices</a>.
</dd>
<dt>
<span class="term">
<code class="literal">open</code>
</span>
</dt>
<dd>
Expand only to open indices.
</dd>
<dt>
<span class="term">
<code class="literal">closed</code>
</span>
</dt>
<dd>
Expand only to closed indices.
</dd>
<dt>
<span class="term">
<code class="literal">hidden</code>
</span>
</dt>
<dd>
Expansion of wildcards will include <a class="xref" href="index-modules.html#index-hidden">hidden indices</a>.
Must be combined with <code class="literal">open</code>, <code class="literal">closed</code>, or both.
</dd>
<dt>
<span class="term">
<code class="literal">none</code>
</span>
</dt>
<dd>
Wildcard expressions are not accepted.
</dd>
</dl>
</div>
<p>Defaults to <code class="literal">open</code>.</p>
</dd>
<dt>
<span class="term">
<code class="literal">fields</code>
</span>
</dt>
<dd>
<p>(Optional, string)
Comma-separated list or wildcard expressions of fields
to include in the statistics.</p>
<p>Used as the default list
unless a specific field list is provided
in the <code class="literal">completion_fields</code> or <code class="literal">fielddata_fields</code> parameters.</p>
</dd>
<dt>
<span class="term">
<code class="literal">completion_fields</code>
</span>
</dt>
<dd>
(Optional, string)
Comma-separated list or wildcard expressions of fields
to include in <code class="literal">fielddata</code> and <code class="literal">suggest</code> statistics.
</dd>
<dt>
<span class="term">
<code class="literal">fielddata_fields</code>
</span>
</dt>
<dd>
(Optional, string)
Comma-separated list or wildcard expressions of fields
to include in <code class="literal">fielddata</code> statistics.
</dd>
<dt>
<span class="term">
<code class="literal">forbid_closed_indices</code>
</span>
</dt>
<dd>
(Optional, boolean)
If <code class="literal">true</code>, statistics are <span class="strong strong"><strong>not</strong></span> collected from closed indices.
Defaults to <code class="literal">true</code>.
</dd>
<dt>
<span class="term">
<code class="literal">groups</code>
</span>
</dt>
<dd>
(Optional, string)
Comma-separated list of search groups
to include in the <code class="literal">search</code> statistics.
</dd>
<dt>
<span class="term">
<code class="literal">level</code>
</span>
</dt>
<dd>
<p>(Optional, string)
Indicates whether statistics are aggregated
at the cluster, index, or shard level.</p>
<p>Valid values are:</p>
<div class="ulist itemizedlist">
<ul class="itemizedlist">
<li class="listitem">
<code class="literal">cluster</code>
</li>
<li class="listitem">
<code class="literal">indices</code>
</li>
<li class="listitem">
<code class="literal">shards</code>
</li>
</ul>
</div>
</dd>
<dt>
<span class="term">
<code class="literal">include_segment_file_sizes</code>
</span>
</dt>
<dd>
(Optional, boolean)
If <code class="literal">true</code>, the call reports the aggregated disk usage of
each one  of the Lucene index files (only applies if segment stats are
requested). Defaults to <code class="literal">false</code>.
</dd>
<dt>
<span class="term">
<code class="literal">include_unloaded_segments</code>
</span>
</dt>
<dd>
(Optional, boolean) If <code class="literal">true</code>, the response includes information from segments
that are <span class="strong strong"><strong>not</strong></span> loaded into memory. Defaults to <code class="literal">false</code>.
</dd>
</dl>
</div>
</div>

<div class="section">
<div class="titlepage"><div><div>
<h3 class="title">
<a id="index-stats-api-example"></a>Examples<a class="edit_me edit_me_private" rel="nofollow" title="Editing on GitHub is available to Elastic" href="https://github.com/elastic/elasticsearch/edit/7.7/docs/reference/indices/stats.asciidoc">edit</a>
</h3>
</div></div></div>
<div class="section">
<div class="titlepage"><div><div>
<h4 class="title">
<a id="index-stats-api-multiple-ex"></a>Get statistics for multiple indices<a class="edit_me edit_me_private" rel="nofollow" title="Editing on GitHub is available to Elastic" href="https://github.com/elastic/elasticsearch/edit/7.7/docs/reference/indices/stats.asciidoc">edit</a>
</h4>
</div></div></div>
<div class="pre_wrapper lang-console">
<pre class="programlisting prettyprint lang-console">GET /index1,index2/_stats</pre>
</div>
<div class="console_widget" data-snippet="snippets/1680.console"></div>
</div>

<div class="section">
<div class="titlepage"><div><div>
<h4 class="title">
<a id="index-stats-api-all-ex"></a>Get statistics for all indices<a class="edit_me edit_me_private" rel="nofollow" title="Editing on GitHub is available to Elastic" href="https://github.com/elastic/elasticsearch/edit/7.7/docs/reference/indices/stats.asciidoc">edit</a>
</h4>
</div></div></div>
<div class="pre_wrapper lang-console">
<pre class="programlisting prettyprint lang-console">GET /_stats</pre>
</div>
<div class="console_widget" data-snippet="snippets/1681.console"></div>
</div>

<div class="section">
<div class="titlepage"><div><div>
<h4 class="title">
<a id="index-stats-api-specific-stats-ex"></a>Get specific statistics<a class="edit_me edit_me_private" rel="nofollow" title="Editing on GitHub is available to Elastic" href="https://github.com/elastic/elasticsearch/edit/7.7/docs/reference/indices/stats.asciidoc">edit</a>
</h4>
</div></div></div>
<p>The following request returns
only the <code class="literal">merge</code> and <code class="literal">refresh</code> statistics
for all indices.</p>
<div class="pre_wrapper lang-console">
<pre class="programlisting prettyprint lang-console">GET /_stats/merge,refresh</pre>
</div>
<div class="console_widget" data-snippet="snippets/1682.console"></div>
</div>

<div class="section">
<div class="titlepage"><div><div>
<h4 class="title">
<a id="index-stats-api-specific-groups-ex"></a>Get statistics for specific search groups<a class="edit_me edit_me_private" rel="nofollow" title="Editing on GitHub is available to Elastic" href="https://github.com/elastic/elasticsearch/edit/7.7/docs/reference/indices/stats.asciidoc">edit</a>
</h4>
</div></div></div>
<p>The following request returns
only search statistics
for the <code class="literal">group1</code> and <code class="literal">group2</code> search groups.</p>
<div class="pre_wrapper lang-console">
<pre class="programlisting prettyprint lang-console">GET /_stats/search?groups=group1,group2</pre>
</div>
<div class="console_widget" data-snippet="snippets/1683.console"></div>
</div>

</div>

</div>
<div class="navfooter">
<span class="prev">
<a href="indices-shards-stores.html">« Index shard stores API</a>
</span>
<span class="next">
<a href="indices-template-exists.html">Index template exists API »</a>
</span>
</div>
</div>

                  <!-- end body -->
                        </div>
                        <div class="col-xs-12 col-sm-4 col-md-4" id="right_col">
                        
                        </div>
                    </div>
                </div>
            </section>
        </div>
    </section>
</div>
<script src="../static/cn.js"></script>
</body>
</html>